<?php
namespace app\admin\validate\user;

use think\Validate;

/**
 * 角色验证
 */
class Permission extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id'         => 'require',
        'permission' => [
            'require',
            'regex' => '/^[\d\.\w]+$/',
        ],
        'title'      => 'require',
        'remark'     => 'max:100',
    ];

    protected $field = [
        'permission' => '节点标识',
        'title'      => '节点名称',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
        'permission.require' => '请输入节点标识',
        'permission.regex'   => '节点标识规则错误',
        'title'              => '请输入节点名称',
        'id'                 => '操作出错',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'create' => ['permission', 'title', 'remark'],
        'edit'   => ['id', 'permission', 'title', 'remark'],
    ];

}
